{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "332126f9-3524-4223-bcc6-24b9818b77b5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from mythic import mythic, mythic_classes\n",
    "import asyncio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abfa531f-5e7a-400b-910c-92a62106ccbe",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "mythic_instance = await mythic.login(\n",
    "        username=\"mythic_admin\",\n",
    "        password=\"mythic_password\",\n",
    "        server_ip=\"mythic_nginx\",\n",
    "        server_port=7443,\n",
    "        timeout=-1\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "654b1348-cf5f-4b2c-9d01-bed63d613a6b",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "async def new_callbacks(mythic_instance: mythic_classes.Mythic):\n",
    "    async for callback in mythic.subscribe_new_callbacks(mythic=mythic_instance, batch_size=10):\n",
    "        print(f\"got new callback: {callback}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "01b5b396-c272-45ae-aafb-3f390599f148",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "async def new_tasks(mythic_instance: mythic_classes.Mythic):\n",
    "    async for task in mythic.subscribe_new_tasks(mythic=mythic_instance, timeout=30):\n",
    "        print(f\"got new task: {task}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7272526-0692-4fee-9ed6-21d7c2929295",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "await asyncio.gather(\n",
    "    new_callbacks(mythic_instance=mythic_instance),\n",
    "    new_tasks(mythic_instance=mythic_instance),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f7216b3-7f87-4853-afe1-cb4052ac554e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
